<VirtualHost *:80>
  ServerName {{ zabbix_url }}
  {% for alias in zabbix_url_aliases %}
  ServerAlias {{ alias }}
  {% endfor %}

  ## Vhost docroot
  DocumentRoot "/usr/share/zabbix"

{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/api', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %}

  <Directory "/usr/share/zabbix">
  {% if zabbix_version == 3.0 %}
    Options FollowSymLinks
    AllowOverride None
    Require all granted
  {% else %}
    AllowOverride None
    Order Allow,Deny
    Allow from all
  {% endif %}
  </Directory>

{% for my_path in directory_paths %}
  <Directory "{{ my_path }}">
  {% if zabbix_version == 3.0 %}
    Require all granted
  {% else %}
    AllowOverride None
    Order Deny,Allow
    Deny from all
  {% endif %}
  </Directory>

{% endfor %}
  ## Logging
  ErrorLog "/var/log/{{ apache_log }}/{{ zabbix_url }}_error.log"
  ServerSignature Off
  CustomLog "/var/log/{{ apache_log }}/{{ zabbix_url }}_access.log" combined

  ## Rewrite rules
  RewriteEngine On
  RewriteRule ^$ /index.php [L]

  ## Custom fragment
  php_value max_execution_time 300
  php_value memory_limit 128M
  php_value post_max_size 16M
  php_value upload_max_filesize 2M
  php_value max_input_time 300
  # Set correct timezone.
  php_value date.timezone {{ zabbix_timezone }}
</VirtualHost>
